package com.dpstudio.ymprestlful.annotation;

import com.dpstudio.ymprestlful.beans.HttpMethod;
import org.jetbrains.annotations.Nullable;

/**
 * @Author: mengxiang.
 * @Date: 2020/6/22.
 * @Time: 11:37 上午.
 * @Description:
 */
public enum YmpHttpMethodAnnotation {

    /**
     * RequestMapping
     */
    REQUEST_MAPPING("net.ymate.platform.webmvc.annotation.RequestMapping", HttpMethod.REQUEST),

    /**
     * RequestParam
     */
    REQUEST_PARAM("net.ymate.platform.webmvc.annotation.RequestParam", null);


    private final String qualifiedName;
    private final HttpMethod method;

    YmpHttpMethodAnnotation(String qualifiedName, HttpMethod method) {
        this.qualifiedName = qualifiedName;
        this.method = method;
    }

    @Nullable
    public static YmpHttpMethodAnnotation getByQualifiedName(String qualifiedName) {
        for (YmpHttpMethodAnnotation springRequestAnnotation : YmpHttpMethodAnnotation.values()) {
            if (springRequestAnnotation.getQualifiedName().equals(qualifiedName)) {
                return springRequestAnnotation;
            }
        }
        return null;
    }

    public HttpMethod getMethod() {
        return this.method;
    }

    public String getQualifiedName() {
        return qualifiedName;
    }

}